;; The Unittests module
;;;;;;;;;;;;;;;;
;; introduced really late in k.Rack
;; we can use this for running simple unittests
;; just by putting this into the code:
;;
;; (test 
;;       "Name of the Test" 
;;        (lambda () (test-this-function))       ;; has to return #t for success
;;        (lambda () (init-the-enviroment))
;;        (lambda (success) ((if (success)
;;                               (clean-up-after-success)
;;                               (clean-up-without-success))
;;                           (general-cleanup)))
                               
(define test (lambda (name test init cleanup)))   ;; start with disabled tests
(define test-simple (lambda (name test result)))

(if (defined? 'use-unit-tests)
    (set! test 
          (lambda (name test cleanup)
             (if (test)
                 (cleanup #t)
                 (begin
                     (print "Test failed:" name)
                     (cleanup #f))))))

(if (defined? 'use-unit-tests)
    (set! test-simple 
          (lambda (name test result)
             (if (equal? test result)
                 '()
                 (print "Test failed:" name)))))

